﻿using System;
using System.Collections.Generic;
using System.Web.Mvc;
using ControleRepresentante.Logic;
using ControleRepresentante.Logic.Models;
using WebSite.ViewModels.Fields;
using WebSite.ViewModels.IndexViewModels;

namespace WebSite.ViewModels.ViewModelExtensions.IndexViewModelExtensions
{
    public static class ClienteJolitexIndexColumns
    {
        public static Guid Codigo = new Guid("1752ed79-caab-4a82-8b56-1d47de359833");
        public static Guid Regiao = new Guid("2752ed79-caab-4a82-8b56-1d47de359833");
    }

    public class ClienteJolitexIndexViewModel : IIndexViewModelExtension
    {
        private readonly string m_CodigoBuscaValue;
        private readonly string m_RegiaoBuscaValue;

        public ClienteJolitexIndexViewModel(string codigoBuscaValue, string regiaoBuscaValue)
        {
            m_CodigoBuscaValue = codigoBuscaValue;
            m_RegiaoBuscaValue = regiaoBuscaValue;
        }

        public IEnumerable<IField> GetSearchFields()
        {
            yield return new TextBoxField("Código Jolitex", "codigo", m_CodigoBuscaValue);
            yield return new TextBoxField("Região", "regiao", m_RegiaoBuscaValue);
        }

        public bool CanEditSpecific(ModelBase modelBase)
        {
            return true;
        }

        public bool CanDeleteSpecific(ModelBase modelBase)
        {
            return true;
        }

        public void RegisterColumns(IndexColumnDefinitionsCollection indexColumnDefinitionsCollection, IIndexColumnsProvider indexColumnsProvider)
        {
            indexColumnDefinitionsCollection.Register(indexColumnsProvider[ClienteJolitexIndexColumns.Codigo], x => ((Cliente)x).ClienteJolitex.Codigo);
            indexColumnDefinitionsCollection.Register(indexColumnsProvider[ClienteJolitexIndexColumns.Regiao], x => ((Cliente)x).ClienteJolitex.Regiao);
        }

        public IEnumerable<TabItem> GetTabs(HtmlHelper htmlHelper)
        {
            return new TabItem[0];
        }
    }
}